<style>
    tbody {
        counter-reset:sectioncounter;
    }
    .SortTd:before {
        content:counter(sectioncounter);
        counter-increment:sectioncounter;
    }
</style>
<div style="clear: both"></div>
<table style="width:100%;text-align: center" id="table" class="layui-table">
        <thead>
        <tr >
            <th  style="text-align: center" nowrap="nowrap"><textarea class="windowName" style="display: none;">${windowName}</textarea>选择</th>
            <th style="text-align: center" nowrap="nowrap">序号</th>
            <th  style="text-align: center" nowrap="nowrap">节点名称</th>
        </tr>
        </thead>
        <tbody>
        <#list userNodeMap?keys as key>
        <tr>
            <td><input type="radio" name="nodeMap" nodeName="${userNodeMap[key]}" value="${key}"/></td>
            <#--自增序号 -->
            <td class="SortTd"></td>
            <#-- nodeName -->
            <td>${userNodeMap[key]}</td>
            <#-- nodeId  -->
            <td style="display: none">${key}</td>
        </tr>
        </#list>
    </table>
</div>
<!--<div class="layui-btn-container" style="text-align: center;position: absolute;bottom: 15px;left: 0px;right: 0px;">-->
    <!--<button class="layui-btn" lay-submit lay-filter="varForm" id="save">保存</button>-->
    <!--<button class="layui-btn layui-btn-danger" id="close">关闭</button>-->
<!--</div>-->
<script>
    layui.use(['table', 'layer'], function () {
        var layer = layui.layer;
        var table = layui.table;
        var setter = layui.setter;
        var $ = layui.$;

        // 获取前弹窗文本域的值
        var jsonStr = $(".thisWindowButton").siblings(".hiddenJson").text();
        var json ;
        if(jsonStr && jsonStr.length>0)
            json=eval('('+jsonStr+')');
        //判断单选框和下拉框的默认选中值
        if(json){
            //非默认
            var nodeId = json.nodeId;
            $('input[name=nodeMap]').each(function () {
                if($(this).val()==nodeId) {
                    $(this).attr("checked", true);
                    return false;
                }
            });
        }

        //保存
        $(document).on('click', '#save', function () {
            //获取选中的按钮
            var hiddenJson = '{nodeId:\"'+$("td input:checked").val()+'\"}';
            var data = $("td input:checked").attr("nodeName");

            //对前弹窗文本域赋值
            $(".hiddenJson").html(hiddenJson);
            $(".textarea").html(data);
            //关闭弹窗
            layer.close(layer.index);
            return false;
        });
        //取消
        $(document).on('click', '#close', function () {
            layer.close(layer.index);
        });
    })
</script>
